<%--
  Created by IntelliJ IDEA.
  User: liudw
  Date: 2015/8/2 0002
  Time: 9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
</head>
<body>


<button type="button" id="json">json</button>
<button type="button" id="keyValue">Key/Value</button>

<script src="/resource/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript">

    $(function(){
       $('#json').click(function(){
           userJson.json();
       });
       $('#keyValue').click(function(){
           userJson.keyValue();
       });
    });

    var userJson = (function () {

        return {
            json: function () {
                $.ajax({
                    type: "POST",
                    contentType:"application/json;charset=utf-8",
                    url: "${ctx}/user/userJson1",
                   // data: "{'userName':'ldw4033','password':'123456'}",
                    success: function(msg){
                        alert( "Data Saved: " + msg );

                    }

                });



            },
            keyValue:function(){
                $.ajax({
                    type: "POST",
                    url: "${ctx}/user/userJson2",
                    //data: "{userName:'ldw4033',password:'123456'}",
                    data: "userName=ldw4033&password=123456",
                    success: function(msg){
                        alert( "Data Saved: " + msg );

                    }

                });
            }
        };

    })();

</script>

</body>
</html>
